package com.tao.YanMoDesignPattern.composite.pattern;

/**
 * @Author Mi_Tao
 * @Date 2023/8/27
 * @Description
 * @Version 1.0
 **/
public class Client
 {

    public static void main(String[] args){
        // 定义多个Composite对象
        Composite root = new Composite();
        Composite c1 = new Composite();
        Composite c2 = new Composite();
        // 定义多个Leaf对象
        Leaf l1 = new Leaf();
        Leaf l2 = new Leaf();
        Leaf l3 = new Leaf();

        // 组合成属性的对象结构
        root.addChild(c1);
        root.addChild(c2);
        c1.addChild(l1);
        c1.addChild(l2);
        c2.addChild(l3);

        // 操作Component 对象
        Component children = root.getChildren(1);
        System.out.println("children = " + children);
    }
}
